package com.example.goodrubish.Garbage;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.ViewTarget;
import com.example.goodrubish.R;

import java.util.List;

public class News_adapter extends ArrayAdapter {
    private int resourceId;

    public News_adapter(Context context, int textViewResourceId, List<News_list> objects){
        super(context,textViewResourceId,objects);
        resourceId=textViewResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        News_list news_list= (News_list) getItem(position);
        View view= LayoutInflater.from(getContext()).inflate(resourceId, parent,false);
        TextView garbageTitle=(TextView)view.findViewById(R.id.garbage_title);
        TextView garbageDescription=(TextView)view.findViewById(R.id.garbage_description);
        //ImageView garbagePicUrl= (ImageView) view.findViewById(R.id.garbage_picUrl);
        String url = news_list.getpicUrl();
        //Glide.with(parent).load(url).into(garbagePicUrl);
        garbageTitle.setText(news_list.getTitle());
        garbageDescription.setText("      "+news_list.getDescription()+"...");
        return view;
    }
}
